Image processing

ABSTRACT

A method of constructing a two-dimensional image includes receiving information describing a two-dimensional N-gon mesh of vertices and constructing an image by coloring at least some of the N-gons based on the respective vertices of the N-gons.

RELATED APPLICATIONS

This application is a divisional of application Ser. No. 09/429,881, filed Oct. 29, 1999, now U.S. Pat. No. 6,798,411. The entire teachings of the above application are incorporated herein by reference.

BACKGROUND

This invention relates to processing an image.

Pictures displayed on computer screens are made up of a very large number of closely packed dots known as pixels. Although a color or black-and-white image may include many different colors or shades of gray, each individual pixel displays only a single color or a single shade of gray. A computer accesses data to determine how to light up each pixel in an image. For example, the data may be a single number corresponding to a shade of gray, or a collection of numbers that instruct the computer to light a given pixel by mixing different amounts of red, green, and blue.

An image the size of a small computer monitor requires data for nearly half-a-million pixels. The large amount of data needed to describe each pixel in an image can consume a lot of space on a computer hard disk or take a long time to download over a network. Thus, it would be advantageous to develop a technique for reducing the amount of data needed to represent an image.

SUMMARY

A method of constructing a two-dimensional image including receiving information describing a two-dimensional N-gon mesh of vertices and constructing an image by coloring at least some of the N-gons based on the respective vertices of the N-gons.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram of image pixels.

FIG. 2 is a diagram of a mesh made from the image pixels.

FIG. 3 is a diagram illustrating the concept of edge-collapsing.

FIG. 4 is a diagram of a mesh after an edge-collapse.

FIG. 5 is a diagram of image pixels determined by a shading algorithm.

FIG. 6 is a flow diagram of a process for encoding, decoding, and displaying an image.

FIG. 7 is a diagram illustrating repeated edge-collapsing.

FIG. 8 is a flow chart of a process for repeated edge-collapsing.

FIG. 9 is a diagram of a mesh.

FIG. 10 is a diagram of mesh centroids.

FIG. 11 is a diagram of a dual graph constructed by connecting centroids.

FIG. 12 is a diagram of a dual graph having cycles.

FIG. 13 is a diagram of a dual graph eliminating cycles.

FIG. 14 is a diagram of a binary tree constructed from the dual graph.

FIG. 15 is a flow chart of a process for encoding a mesh.

FIGS. 16–20 are diagrams illustrating update records that can be used to progressively transmit mesh connectivity.

FIG. 21 is a diagram of a computer.

DETAILED DESCRIPTION

Introduction

FIG. 1 shows a magnification of pixels 102 a–102 k in one corner of a two-dimensional image 100. As shown in FIG. 2, each set of three pixels can form the corners (vertices) of a triangle. For example, pixels 102 b, 102 c, and 102 f are the vertices of triangle 104 a having sides (edges) 106 a, 106 b, and 106 c. Neighboring triangles share vertices. For example, vertex 102 b is a vertex of triangle 104 b in addition to triangle 104 a. This collection of vertices and their inter-connections is known as a triangular mesh.

Typically, the triangle lines shown in FIG. 2 are not displayed on a computer screen. FIG. 2, however, does illustrate a way of handling pixels in a two-dimensional image that can both reduce the amount of data needed to represent an image and can speed and enhance special effects such as zooming in on the image.

For example, as shown in FIGS. 2–4, portions of the mesh can be selectively eliminated without substantially reducing the quality of the image as perceived by a human eye. For example, instructions may evaluate the triangle edges in FIG. 2 to determine which edge can be removed with the least impact on the appearance of the image. For example, the instructions may determine that removing edge 106 f would not substantially alter the image. The instructions can then perform an “edge-collapse”.

Conceptually, an edge collapse, as shown in FIG. 3, is like pushing pixel 102 f down into pixel 102 i and dragging all of pixel 102 f's connections to other pixel's along the way. As shown in FIG. 4, the edge-collapsing operation reduced the number of triangles by eliminating pixel 102 f, the edge-between pixel 102 f and pixel 102 i, and edges 106 e and 106 f. The remaining triangles, such as triangle 104 a, are stretched to cover the image. Since fewer triangles cover the image, fewer triangle vertices and their connectivity information are needed to describe the image's triangular mesh. Thus, an image can be described using less data.

Whether or not instructions reduce the mesh, expressing a two-dimensional image as a flat mesh permits the use of a variety of techniques used by 3D graphics applications. For example, pixels bounded by a triangle in the mesh can also be colored using a 3D graphics technique known as Gouraud shading (also called intensity interpolation shading or color interpolation shading).

Gouraud shading uses the colors of triangle vertices to color-in the triangle area between the vertices. Many standard APIs (Application Program Interfaces), such as DirectX and OpenGL, and popular 3D Graphics Accelerator cards (e.g., 3D cards available from Matrox™ and Diamond™) offer Gouraud shading functions in their APIs. The Gouraud shading functions provided by these cards are used by real-time 3D video games to quickly shade triangles in three-dimensional triangular meshes that form spaceships and other 3D objects. By creating a flat mesh from an image, software (e.g., a browser) displaying an image can take advantage of the fast hardware-implemented coloring routines offered by these 3D graphics cards even though the images are only two-dimensional. This technique can speed image special effects such as zooming in or out of an image. For example, as shown in FIG. 5, a user can zoom in on triangle 104 a.

Zooming in or out is achieved by multiplying the vertex coordinates (or a copy of the vertex coordinates) by a scalar value. This has the effect of increasing the distance between vertex coordinates and increasing the size of the triangles. The triangles now require more pixels to fill the interior and edges. Thus, while vertices 102 b and 102 c were neighbors in FIG. 3, pixel 108 a now separates the vertices 102 b, 102 c after magnification of the image. Vertices 102 b, 102 c and vertex 102 i, however, still form the vertices of triangle 104 a, though triangle 104 a is now much larger than in FIG. 3. A Gouraud shading function (hardware or software) can quickly compute color values for pixels 108 a–108 g within triangle 104 a.

Many other shading techniques may be used instead of, or in combination with, Gouraud shading. For example, a system may use flat-shading or wire-frame shading. In flat shading, each pixel of a triangle is colored using the average color of the triangle vertices. Wire-frame shading is like Gouraud shading, except the interior pixels are not colored, only the edges. This gives the image an interesting computer-like effect.

Image Processing

FIG. 6 shows image encoding software 110 that encodes an image for storage and display by image decoding software 120. The encoding 110 and decoding software 120 may be on different computers such as computers connected via the Internet. The encoded image may be transmitted statically or progressively. A statically transmitted image can be decoded after all encoded information has been received. A progressively transmitted image can be displayed incrementally as the information is received. Of course, the encoding 110 and decoding 120 software may execute on the same computer.

As shown in FIG. 6, the encoding software 110 receives a two-dimensional image, that is, an image having pixels that are in the same plane. The software 110 uses pixels in the image to define 112 a mesh. The mesh may be a triangular mesh, known as a highly-tessellated mesh, or another type of N-gon mesh where N represents the number of sides in the geometric shapes in the mesh. That is, an N-gon mesh can be a quadrilateral mesh (N=4), a polygon mesh (N=5), etc. The mesh may be represented by an array of vertex coordinates and an array of faces where each face has indices into the vertex coordinate array.

Prior to mesh reduction, the software 110 may apply filters to the mesh to identify important edges or to apply special effects that are transmitted as part of the image. The information gained in this pre-processing may guide the edge selection during mesh reduction.

After creating the mesh 112, the software 110 then uses mesh reduction techniques to simplify the mesh. A wide variety of mesh reduction techniques can be used such as edge-collapsing, vertex clustering, and/or vertex decimation. After simplification, the software 110 encodes the mesh for later reconstruction into an image.

The image decoding software 120 decodes the-encoded mesh 118 and can use a shading technique 144 to display the image. A user may choose different image special effects 126 such as image scaling (e.g., zooming-in and out), image rotation in any x, y, or z direction, or image shearing. The image may also be perturbed using a modulated sin or cosine function to create a wave-like effect. These special effects transform 126 the coordinates of the mesh vertices, for example, by moving them closer together or farther apart. After determining or receiving the new coordinates of the triangle vertices 128, the software 120 can again use Gouraud shading 124 to “color-in” each triangle.

Edge Collapsing

One type of mesh reduction technique is known as edge-collapsing. FIG. 7 shows repeated edge-collapsing of a mesh 130, 136, 142. As shown, each edge-collapse -reduces the number of triangles in the mesh. Thus, after collapsing only two edges 134, 140, a simplified three triangle mesh 142 can cover the same area initially covered by a more intricate seven triangle mesh 130. Empirically, selectively eliminating nearly 80% of mesh edges often does not perceptibly degrade a displayed image. Software may enable a user to control the amount of edge-collapsing.

FIG. 8 shows a process 114 for using edge-collapsing to simplify a mesh. The process 114 identifies mesh edges that do not contribute significantly to the image. For example, the process 114 can determine 144 an “error-metric” value for each edge and collapse 146 edges having the lowest error metric values. Recalculation-of error-metric values and edge-collapsing can repeat 148 until the process 114 eliminates 146 a predefined or dynamically determined number of edges or until the lowest error metric values exceed some empirical or user set threshold. Another method collapses edges with the lowest error metric until a total error-threshold is exceeded. The total error is defined using an image processing heuristic such as the sum of the squared differences between the original image pixels and the current, lower-resolution image pixels.

In one embodiment, the process 114 uses the techniques described in a SIGGRAPH 97 article entitled “Surface Simplification Using Quadric Error Metrics” by Michael Garland and Paul S. Heckbert (Michael Garland and Paul S. Heckbert. Surface Simplification Using Quadric Error Metrics, Proceedings of SIGGRAPH 97, Computer Graphics Proceedings, Annual Conference Series, pp. 209–216 (August 1997, Los Angeles, Calif.); Addison Wesley; Edited by Turner Whitted; ISBN 0-89791-896-7). The article describes a technique designed and used for simplifying surface topologies in three-dimensional meshes (e.g., smoothing small jagged three-dimensional spikes or bumps). The technique identifies a set of planes whose intersection meet at a vertex and defines the error of the vertex with respect to this set of planes as the sum of squared distances to the planes. Instead of using this technique to smooth a three-dimensional surface, however, the encoding software can use the error-metric to identify edges that can be removed and cause the least amount of perceptible image color (or greyscale) degradation.

The three-dimensional error-metric technique operates on vertices having x, y, and z coordinates. Since the co-planar coordinates of the two-dimensional mesh can have only x and y values, in greyscale pictures, the z value for each vertex coordinate can be set to the greyscale value of the vertex.

In a color embodiment, the process 114 transforms the red, green, and blue (RGB) values of each pixel into YUV values in the luminance/chrominance color space. Y, u, and v can be directly computed as functions of R, G, and B. In the YUV color space, the Y value dominates the u and v values. Hence, the Y value of each vertex can be fed to the error-metric function as the z value for each vertex.

In yet another embodiment, the process applies the Quadric Error Metric to the Y, u, and v components of each vertex. The resulting error metrics (3 per edge) are weighted and averaged together to form a single error metric which is feed into an edge-collapsing function.

Mesh Encoding

After mesh reduction (if applied), the resulting mesh can be compactly encoded for storage and subsequent decoding. FIG. 9 shows connected vertices 100 l–100 s of a triangular mesh. A large number of other triangular meshes could be formed from the same set of vertices 100 l–100 s. For example, instead of a triangle having vertices 100 l, 100 m, and 100 o, a triangle could have vertices of 100 l, 100 m, and 100 n (the dotted triangle). Thus, information must be encoded that describes not only the vertices' coordinates and colors, but also how the triangles fit in the mesh (i.e., their connectivity).

A wide variety of techniques can be used to encode a mesh. FIGS. 10–14 illustrate a technique for representing a mesh as a binary tree. In FIG. 10, software determines the center or centroid 150 a–150 h of each triangle in the mesh of FIG. 9. As shown in FIG. 11, by connecting each centroid 150 a–150 h to centroids in neighboring triangles, and connecting border centroids 150 a, 150 b, 150 d, 150 f, 150 h to the edge of their respective mesh triangles, software can create a dual graph from the original mesh configuration. As shown in FIG. 12, the dual graph alone can describe a mesh arrangement where each edge is used in no more than two triangles.

As shown in FIG. 12, a dual graph may include loops or cycles such as a cycle formed by graph edges 152 g, 152 i, 152 j, 152 m, and 152 h and a cycle formed by graph edges 152 b, 152 c, 152 f, 152 g, and 152 e. By breaking dual graph edges that form cycles, software can “twist” the mesh into a binary tree. To break cycles, software randomly selects an edge (e.g., edge 152 a) of the dual graph as the root and traverses the graph by always choosing a left branch if possible. The software records which branch intersections have been visited. When the software returns to an intersection previously encountered, the edge leading to the intersection is selected for breaking. For example, the dual graph of FIG. 13, may be traversed as shown by arrow 151.

As shown in FIG. 14, once software breaks the cycles, traversing the dual graph can produce a binary tree. The broken cycles are represented as “pops” and “pushes”. To “untwist” the binary tree into its original shape, the first “pop” 152 a is reconnected with the last “push” 154 b, the second “pop” 156 a is reconnected with the second-to-last “push” 156 b, etc. The binary tree can then be encoded using any number of recursive or non-recursive algorithms (e.g., a preorder recursive algorithm). Other trees can be used in lieu of a strictly binary tree. This may be preferred when a mesh is made of N-gons other than triangles.

To summarize, FIG. 15 shows a process 116 for encoding a mesh. After constructing a dual graph from a mesh 160 and breaking graph cycles 162, traversing the dual graph yields a binary tree 164. Algorithms can encode the binary tree for inclusion with data describing the coordinates of vertices in the mesh, and the colors (or grey-scale value) of each vertex.

The mesh representation of the image could be encoded using other techniques including techniques that support progressive mesh construction and rendering. For example, the mesh could be encoded by compressing the actions needed to reconstruct the mesh progressively. Progressive transmission enables a system to display construction of the mesh as progressive information arrives instead of awaiting complete transmission.

FIG. 16 is a diagram illustrating a series of edge-collapse operations 310–370 upon a mesh that continues until no mesh vertices remain. Each such operation may be described in an update record that can be used to reconstruct the mesh from'scratch later. As shown, each operation is described as inheritance of a child vertex's connections by a parent vertex that may alter or delete existing mesh faces. FIG. 17 shows the effect of the operations on a table of faces 410–480. FIGS. 18 and 19 illustrate how the information in FIGS. 16 and 17 can be encoded in a series of update records 510–570 that describe how to reverse the operations and reconstruct the mesh. FIG. 20 shows an efficient scheme for encoding an update record. As shown, update record 570 can be compactly encoded in data structure 730. The data structure 730 codes a parent vertex as an index into a table of vertices that includes the vertex coordinates. The index is encoded using an unsigned binary number using ceiling (log₂m) bits, wherein ceiling (x) is an operation to round x up to the next whole number. The child vertex is not encoded because it is always the next vertex index. All the faces that contain the parent index in the order they are found in the face table 720 are enumerated. The enumeration is performed by a state machine. The structure 730 includes a single bit for each face 732 including the parent vertex. If this bit is at a first logical state (e.g., 0) then the face is not modified. If this bit is at a second logical state (e.g., 1) then the face is modified. Since all new faces contain a parent vertex, a child vertex, and one other vertex, it is necessary to enumerate all of the other vertices that are connected to the parent vertex. The enumeration is performed by a state machine. The order is determined by the order in which they are found in the face table 720.

EMBODIMENTS

FIG. 21 shows a computer for processing images using the techniques described above. The computer includes a processor 174, memory 176, a storage medium 180 (e.g., hard disk), and preferably a 3D graphics card 178 that provides 3D shading routines. The storage medium 180 stores instructions for encoding 110 and decoding 120 images for display on a monitor 172. The instructions may be called from a variety of programs such as a browser 182.

The techniques described here, however, are not limited to any particular hardware or software configuration; they may find applicability in any computing or processing environment. The techniques may be implemented in hardware or software, or a combination of the two. Preferably, the techniques are implemented in computer programs executing on programmable computers that each include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and one or more output devices. Program code is applied to data entered using the input device to perform the functions described and to generate output information. The output information is applied to one or more output devices.

Each program is preferably implemented in a high level procedural or object oriented programming language to communicate with a computer system. However, the programs can be implemented in assembly or machine language, if desired. In any case, the language may be a compiled or interpreted language.

Each such computer program is preferable stored on a storage medium or device (e.g., CD-ROM, hard disk or magnetic diskette) that is readable by a general or special purpose programmable computer for configuring and operating the computer when the storage medium or device is read by the computer to perform the procedures described in this document. The system may also be considered to be implemented as a computer-readable storage medium, configured with a computer program, where the storage medium so configured causes a computer to operate in a specific and predefined manner.

Other embodiments are within the scope of the following claims. For example, while described as operating on a two-dimensional image, the image may be a single frame in a series of video frames. In this case, the encoding of the image may be described as changes to the mesh instead of completely re-encoding the mesh for each frame. 

1. A method of constructing a two-dimensional image, comprising: receiving information describing a two-dimensional N-gon mesh of vertices; and constructing a two-dimensional image by coloring at least some of the N-gons based on the respective vertices of the N-gons.
 2. The method of claim 1 wherein receiving the information comprises receiving information describing mesh connectivity, vertex locations, and vertex display values.
 3. The method of claim 1 wherein the N-gons comprise triangles.
 4. The method of claim 1 wherein coloring comprises using a Gouraud shading algorithm.
 5. The method of claim 1 wherein coloring comprises calling a function provided by graphics hardware.
 6. The method of claim 1 further comprising recoloring after coordinates of vertices in the mesh have been altered.
 7. The method of claim 6 wherein mesh vertex coordinates are altered by zooming-in or scaling.
 8. The method of claim 6 wherein mesh vertex coordinates are altered by rotation.
 9. The method of claim 1 wherein receiving comprises receiving a series of records describing how to construct the mesh.
 10. A computer program product, disposed on a computer readable medium, for constructing a two-dimensional image, the program including instructions for causing a processor to: receive information describing a two-dimensional N-gon mesh of vertices; and construct a two-dimensional image by coloring at least some of the N-gons based on the respective vertices of the N-gons.
 11. The computer program of claim 10 wherein the information comprises information describing mesh connectivity, vertex locations, and vertex display values.
 12. The computer program of claim 10 wherein the N-gons comprise triangles.
 13. The computer program of claim 10 wherein coloring comprises using a Gouraud shading algorithm.
 14. The computer program of claim 10 wherein coloring comprises calling a function provided by graphics hardware.
 15. A system for constructing a two-dimensional image, the system including: a processor; and a computer readable medium for storing instructions that cause the processor to: receive information describing a two-dimensional N-gon mesh of vertices; and construct an image by coloring at least some of the N-gons based on the respective vertices of the N-gons. 